{% macro button(label, link, kind='default', as='a', type='button') %}
{%- set classes = resolve_class([
'inline-flex items-center justify-center px-3 py-1 text-base leading-5 rounded-md focus:outline-none',
{
'text-white bg-gray-900 hover:bg-gray-800 active:bg-gray-700 focus-visible:ring focus-visible:ring-gray-400': kind ==
'primary',
'text-gray-800 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus-visible:ring focus-visible:ring-gray-400': kind ==
'default',
}
]) -%}
{%- if as == 'a' -%}
<a class="{{ classes }}" href="{{ link }}">{{ label }}</a>
{%- else -%}
<button class="{{ classes }}" type="{{ type }}">{{ label }}</button>
{%- endif -%}
{% endmacro %}

{% macro link(label, url, class, blank=False) %}
<a class="text-gray-600 hover:text-gray-800 {{ resolve_class(class) }}" href="{{ url | abs_url }}" {% if blank %}
	target="_blank" {% endif %}>{{ label }}</a>
{% endmacro %}

{% macro badge_gray(title) %}
<span class="inline-block px-3 py-1 text-sm text-gray-700 rounded-md cursor-default bg-gray-100">
	{{ title }}
</span>
{% endmacro %}

{% macro badge_green(title) %}
<span class="inline-block px-3 py-1 text-sm text-green-800 rounded-md cursor-default bg-green-200">
	{{ title }}
</span>
{% endmacro %}

{% macro breadcrumbs(items) %}
<nav class="flex items-center text-sm font-medium leading-5">
	{%- for item in items -%}
	<a href="{{ item.url }}"
		class="text-base {% if not loop.last %} text-gray-900 {% else %} text-gray-500 {% endif %} {% if not loop.last %} hover:text-gray-600 {% endif %} focus:outline-none focus:underline">
		{{ item.label }}
	</a>

	{%- if not loop.last -%}
	<svg class="flex-shrink-0 mx-2" xmlns="http://www.w3.org/2000/svg" width="6" height="8" viewBox="0 0 6 8"
		fill="none">
		<path d="M1.25 7.5L4.75 4L1.25 0.5" stroke="#1F272E" stroke-linecap="round" stroke-linejoin="round" />
	</svg>
	{%- endif -%}
	{%- endfor -%}
</nav>
{% endmacro %}

{% macro form(fields, action='') %}
<form action="/api/method/{{ action }}" method="POST">
	<section class="space-y-4">
		{%- for df in fields -%}
		<p class="space-y-2">
			<label class="block text-base" for="{{ df.fieldname }}">{{ df.label }}</label>
			{%- if df.fieldtype == 'Select' -%}
			<select class="w-full form-select" name="{{ df.fieldname }}" id="{{ df.fieldname }}">
				{%- for option in df.options or [] -%}
				<option value="{{ option.value }}">{{ option.label }}</option>
				{%- endfor -%}
			</select>
			{%- else -%}
			<input type="text" id="{{ df.fieldname }}" class="w-full form-input" name="{{ df.fieldname }}">
			{%- endif -%}
		</p>
		{%- endfor -%}
		<input type="text" name="csrf_token" value="{{ frappe.session.csrf_token }}" hidden>
	</section>
	<p class="mt-8 text-center">
		{{ button('Submit', as='button', type='submit', kind='primary') }}
	</p>
</form>
{% endmacro %}


{% macro five_star_rating(rating=0.0) %}
<div class="flex flex-row space-x-1">
	{% for i in range(1, 6) %}
	<!-- Star Icon -->
	<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">
		<path
			d="M6.56866 0.735724C6.76184 0.406233 7.23816 0.406233 7.43134 0.735725L9.16063 3.68535C9.23112 3.80559 9.34861 3.89095 9.48475 3.92084L12.8244 4.65401C13.1974 4.73591 13.3446 5.18892 13.091 5.47446L10.8201 8.03059C10.7275 8.1348 10.6826 8.27291 10.6963 8.41162L11.031 11.8144C11.0684 12.1945 10.683 12.4745 10.3331 12.3214L7.20032 10.9516C7.07261 10.8958 6.92739 10.8958 6.79968 10.9516L3.66691 12.3214C3.31696 12.4745 2.9316 12.1945 2.96899 11.8144L3.30371 8.41162C3.31736 8.27291 3.27248 8.1348 3.17991 8.03059L0.90903 5.47446C0.655358 5.18892 0.802551 4.73591 1.17561 4.65401L4.51525 3.92084C4.65139 3.89095 4.76888 3.80559 4.83937 3.68535L6.56866 0.735724Z"
			fill="{{ '#C0C6CC' if i > rating else '#ECAC4B' }}" />
	</svg>
	{% endfor %}
</div>
{% endmacro %}